<script type="text/javascript">
$(function(){
	var pg = App.office.meetingPicker.ui, pp = pg.params;
	//
	var gd = pg.find('.grid').mac('grid', {
		key: 'id',
		cols: [{
			field: 'id', width: 24,
			title: pp.multi? '<input type="checkbox" name="all" />':'',
			render : function(r) {
				return '<input type="checkbox" name="keys" value="' + r.id + '"/>';
			}
		},{
			field: 'code', title: '编号', width: 160, sort: true,
		},{
			field: 'name', title: '名称', width: 240, sort: true
		},{
			field: 'ver', title: '版本', width: 120, sort: true
		}],
		loader: {
			url: App.office.ctx + '/com/list.do',
			params: { pageNo: 1, pageSize: 20 },
			autoLoad: true
		},
		afterLoad: function(dd, po, me){
			me.find('.tr').each(function(n,tr){
				$(tr).dblclick(function(){
					pg.seek('ok').click();
				});
			});
		},
		pagerLength: 10
	});
	pg.seek('all').click(function(){
		gd.seek('keys').prop('checked', $(this).prop('checked'));
	});
	pg.seek('key').keydown(function(e){
		if (e.keyCode == 13) {
			gd.load({ key: $(this).val() });
		}
	});
	pg.seek('find').click(function(){
		gd.load({ key: pg.seek('key').val() });
	});
	pg.seek('cancel').click(function() {
		pg.close();
	});
	pg.seek('ok').click(function() {
		var sl = [], a = gd.selected;
		if (a) {
			a = a.attr('name');
			sl = [ a ];
		}
		if (pp.multi) {
			var ms = $.map(gd.find('input[name=keys]:checked'), function(c) {
				return c.value;
			});
			if (ms.length > 0)
				sl = ms;
		}
		pg.callback($.map(sl, function(c) {
			return gd.data[c];
		}));
		pg.close();
	});
	//mac.setLanguage();
});
</script>
<div class="form">
	关键字：<input type="text" name="key" />&nbsp;
	<button name="find">查找</button>
</div>
<div id="main">
	<div class="grid"></div>
</div>
<div style="text-align: center">
	<button name="ok">确定</button>
	&nbsp;
	<button name="cancel">取消</button>
</div>